<?php
class Mvc_Ajax_jEditable{
	
	private $id;
	private $value;
	private $col;
	
	private $rowId;
	
	private $colId;
	
	public function __construct(Mvc_Request $request){
		list($row,$col) = explode("|",$request->getPost("id"));
		list(,$this->id) = explode(":",$row);
		list(,$this->col) = explode(":",$col);
		
		$this->value = $request->getPost("value");
		
		$this->value = ("null" == $this->value) ? "" : $this->value;
		
		if($request->hasPost("row_id")){
			$this->rowId = $request->getPost("row_id");
		}
	}
	
	public function getId(){
		return $this->id;
	}
	
	public function getValue(){
		return is_array($this->value) ? implode(",", $this->value) : $this->value;
	}
	
	public function getCol(){
		return $this->col;
	}
	
	public function edit($obj){
		$obj->{$this->getCol()} = $this->getValue();
		return $obj;
	}
}